<script>
function getby_code(code){
     var price= $('#price').val()
	 var split = price.split(',');
	 var price1 = split[0];
     var price2 = split[1];
	var name= $('#product_name').val()
	var category = $('#product_category').val()
	var company = $('#company_name').val()
	var location =$('#location').val()
	
$.post("<?= site_url('product/transfer/getby_code')?>",{price1:price1,price2:price2,location:location, code : code,location:location, name:name, category: category, company : company }, function(msg){
							if(msg){
								$("#report").show();
								$("#report").html(msg);
								
							}
		
						})
	
}
function getby_name(name){
 var price= $('#price').val()
	 var split = price.split(',');
	 var price1 = split[0];
     var price2 = split[1];
	var code= $('#product_code').val()
	var category = $('#product_category').val()
	var company = $('#company_name').val()
    var location =$('#location').val()
$.post("<?= site_url('product/transfer/getby_name')?>",{price1:price1,price2:price2,location:location, name : name, code : code, category: category ,company : company }, function(msg){
							if(msg){
									$("#report").show();
								$("#report").html(msg);
								
						}
		
						})
	
}

function getby_category(category){
 var price= $('#price').val()
	 var split = price.split(',');
	 var price1 = split[0];
     var price2 = split[1];
		var code= $('#product_code').val()
	var name = $('#product_name').val()
	var company = $('#company_name').val()
    var location =$('#location').val()
$.post("<?= site_url('product/transfer/getby_category')?>",{price1:price1,price2:price2,location:location,category : category, code : code, name:name, company : company}, function(msg){
							if(msg){
									$("#report").show();
								$("#report").html(msg);
								
						}
		
						})
	
}


function getby_company(company){
	//alert(company)
	 var price= $('#price').val()
	 var split = price.split(',');
	 var price1 = split[0];
     var price2 = split[1];
	var code= $('#product_code').val()
	var name = $('#product_name').val()
	var category = $('#product_category').val()
	var location=$('#location').val()
$.post("<?= site_url('product/transfer/getby_company')?>",{price1:price1,price2:price2,location:location,company:company, category : category, code : code, name:name}, function(msg){
							if(msg){
								//alert(msg)
									$("#report").show();
								$("#report").html(msg);
								
						}
		
						})
	
}
function getby_location(location){
     var price= $('#price').val()
	 var split = price.split(',');
	 var price1 = split[0];
     var price2 = split[1];
	var code= $('#product_code').val()
	var name = $('#product_name').val()
	var category = $('#product_category').val()
	var company=$('#company_name').val()
	
$.post("<?= site_url('product/transfer/getby_location')?>",{price1:price1,price2:price2,location:location, company:company, category : category, code : code, name:name}, function(msg){
							if(msg){
								//alert(msg)
									$("#report").show();
								$("#report").html(msg);
								
						}
		
						})
	
}
function getby_price(price){
 var split = price.split(',');

var price1 = split[0];
var price2 = split[1];

    var location= $('#location').val()
	var code= $('#product_code').val()
	var name = $('#product_name').val()
	var category = $('#product_category').val()
	var company=$('#company_name').val()
	
$.post("<?= site_url('product/transfer/getby_price')?>",{price1:price1,price2:price2,location:location, company:company, category : category, code : code, name:name}, function(msg){
							if(msg){
								//alert(msg)
									$("#report").show();
								$("#report").html(msg);
								
						}
		
						})
	
}



</script>

<h2 style="background-color:#368EE0; color:white; font-size:20px; padding:5px;">Inventory Stock on Hand Report
            <span><?php echo date('d M y');?></span></h2>


<div class="row-fluid">
 </div>
		<br>
<section >
  <div class="row-fluid intelligence-filters">
    <div class="span12 ser">
     <div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="?"></div>
        <div class="row-fluid">
          <div class="span3">
            <label for="q_name_cont">Product Name</label>
            <span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span><input type="text" id="product_name"   onkeyup="getby_name(this.value)"placeholder="">

            <label for="q_product_name_cont">Category</label>

              <select  id="product_category" onchange="getby_category(this.value)" class="chzn-select"placeholder="All Type" tabindex="-1">
			<option value=""> ALL Type</option>
			<?php foreach ($category as $categorys){?>
			<option value="<?php echo $categorys->name;?>" ><?php echo $categorys->name;?></option> <?php } ?></select>

         </div>
          <div class="span3">
            
			
            <label for="q_sku_cont">Product Code</label>
            <span role="status" aria-live="polite" class="ui-helper-hidden-accessible"></span><input id="product_code" onkeyup="getby_code(this.value)"  type="text" value="" class="ui-autocomplete-input" autocomplete="off">

            <label for="q_product_product_type_eq">Company</label>
            <select  id="company_name" class="chzn-select"onchange="getby_company(this.value)" placeholder="All Company" tabindex="-1">
			<option value=""> ALL Company </option>
			<?php foreach ($company as $companys){?>
			<option value="<?php echo $companys->name;?>" ><?php echo $companys->name;?></option> <?php } ?></select><div class="default selectize-control selectize single full-width" style="display: inline-block;"><div class="selectize-input items has-options not-full"></div><div class="selectize-dropdown" style="display: none; width: 210px; top: 28px; left: 0px;"><div class="selectize-dropdown-content"></div></div></div>
          </div>
          <div class="span3">
            <label for="q_product_tags_cont">Price</label>
           <select  id="price" onchange="getby_price(this.value)"   ><option value="," > All Price</option>
	
			<option value="100,200"> Rs.100 to Rs.200</option>
			<option value="200,500"> Rs.200 to Rs.500</option>
			<option value="500,1000"> Rs.500 to Rs.1000</option>
			<option value="1000,"> Above Rs.1000</option>
			</select>

            <label for="location_id">Branch</label>
            <select class="chzn-select" id="location"  onchange="getby_location(this.value)" ><option value="" > ALL Location</option>
			<?php foreach ($branch as $branchs){?>
			<option value="<?php echo $branchs->id;?>" ><?php echo $branchs->name;?></option> <?php } ?>
			</select>
          </div>
          
        </div>
</form>    </div>
  </div>
  <br>

 
</section>
<?php $stock=0; $purchase_price=0; $selling_price=0?>
<?php foreach ($all_product as $reports)
{
$data=$reports->opening_stock;
$data1=$reports->purchase_price;
$data2=$reports->selling_price;
$stock=intval($stock+$data);
$purchase_price=intval($purchase_price+($data*$data1));
$selling_price=intval($selling_price+($data2*$data));

}
?>
<div class="line"></div>
<div class="row-fluid">
<div class="span12" id="report" >
 <div class="row-fluid intelligence-data ptl tcenter ">
  <div class="span12 sers">
    <div class="span3 data-well">
      <h4 align="center" ><?php echo $stock;?></h4>
      <p class="light-text" align="center">Total Units on Hand</p>
    </div>

    <div class="span3 data-well">
      <h4 align="center" >Rs.<?php echo $purchase_price;?>.00</h4>
      <p align="center" class="light-text">Cost Value of Stock on Hand</p>
    </div>

    <div class="span3 data-well">
      <h4 align="center" >Rs.<?php echo $selling_price;?>.00</h4>
      <p align="center" class="light-text">Retail Value Stock on Hand</p>
    </div>


    <div class="span3 data-well">
      <h4 align="center" >Rs.<?php $profit=intval($selling_price-$purchase_price); echo $profit;?>.00</h4>
      <p align="center" class="light-text">Profit Value of Stock on Hand</p>
    </div>
  </div>
</div> 
</div>	